#!/usr/bin/env python
#-*-conding:utf-8-*-

import requests # 发送http请求
from bs4 import BeautifulSoup # 解析html
import lxml # 解析器 中文不乱码
import os #创建文件夹

path = 'C:/Users/Administrator/Desktop/tmp' #保存文件路径
folder = '/tencent/'

headers = {
	'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36 Core/1.63.6788.400 QQBrowser/10.3.2864.400',
}

video_url = 'https://apd-30f54de1489773d7e874f8a69b1714c7.v.smtcdns.com/omts.tc.qq.com/AQYAGmaGuczoSrveXrBDeVdtDNlNG6Q-2wRJVHthHP18/uwMRJfz-r5jAYaQXGdGnC2_ppdhgmrDlPaRvaV7F2Ic/uf_dsjzwR__Q4lIp34hnHlKFjhzVX3MWzSOwQRuYKhGK3dyNeU9dR9IKb4IN7bouv8JownCnI-2xbkNie59pWowxaMxbVObc1dmm8qTllsgFncqVsiZZ0WGGof_bSPr7lijgWRsKleb8ZTpPtnux8cplTRhzAw4D/00_j083275ym3y.321002.1.ts?index=0&start=0&end=9720&brs=0&bre=633183&ver=4'

video_url = 'https://v.qq.com/x/page/s0832vlx8oq.html'

# 下载video
def download_video(video_url, path, headers):
	video = requests.get(video_url,  headers=headers, timeout=60)
	name = path+'/'+video_url.split('/')[-1].split('?')[0]
	with open(name, 'ab') as f:
		f.write(video.content)

download_video(video_url, path, headers)